package com.lzb.newloan;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lzb.newloan.utils.BaseActivity;
import com.lzb.newloan.utils.Config;
import com.lzb.newloan.utils.HttpUtils;
import com.lzb.newloan.view.MyProgressDialog;

public class AskMoneyActivity extends BaseActivity implements OnClickListener {

	private TextView money;
	private Button confirm;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_ask_money);
		initView();
	}

	private void initView() {
		SharedPreferences sp = getSharedPreferences("config", 0x0000);
		userId = sp.getString("userid", "");
		allmoney = getIntent().getStringExtra("money");
		TextView title_txt_center = (TextView) findViewById(R.id.title_txt_center);
		title_txt_center.setText("申请提现");
		RelativeLayout backpress = (RelativeLayout) findViewById(R.id.backpress);
		backpress.setOnClickListener(this);
		money = (TextView) findViewById(R.id.money);
		money.setText("￥"+allmoney);
		confirm = (Button) findViewById(R.id.confirm);
		confirm.setOnClickListener(this);
	}

	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			String result = msg.obj.toString();
			switch (msg.what) {
			case Config.CODE_URL_ERROR:
				Toast.makeText(AskMoneyActivity.this, "url错误",
						Toast.LENGTH_SHORT).show();
				break;
			case Config.CODE_NET_ERROR:
				Toast.makeText(AskMoneyActivity.this, "网络错误",
						Toast.LENGTH_SHORT).show();
				break;
			
			default:
				break;
			}
		};
	};
	private String userId;
	private MyProgressDialog dialog;
	private String allmoney;

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.backpress:
			finish();
			break;
		case R.id.confirm:
			dialog = new MyProgressDialog(AskMoneyActivity.this, "");
			dialog.show();
//			
				HttpUtils.doPostAsyn(Config.ASKMONEY_CORD + "&userid=" + userId, "",mHandler,
						Config.CODE_ASKMONEY);
//			}
			
			break;
		default:
			break;
		}
	}

	@Override
	public void processMessage(Message message) {
		// TODO Auto-generated method stub
		
	}

}
